<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<jsp:include page="/main/header.jsp"></jsp:include>
<title>예약 리스트</title>
<%@ page import="com.popcorn.rmsystem.controller.*" %>
<%@ page import="com.popcorn.rmsystem.dao.*" %>
<%@ page import="com.popcorn.rmsystem.model.*" %>
<%@ page import="java.util.*" %>
<link rel="stylesheet" type="text/css" href="../css/reset.css" />
<link rel="stylesheet" type="text/css" href="../css/common.css" />
<link rel="stylesheet" type="text/css" href="../css/index.css" />
<script type="text/javascript">
function pageload(btn){
	var page = document.getElementById("pageidx").value;
	var last = document.getElementById("lastpage").value;
	if(btn.value=="이전페이지")
		page--;
	else if(btn.value=="다음페이지")
		page++;
	if(page == 0) page = 1;		
	if(page-1 == last) page--;
	
	window.location.href = 'RMSListDB.bo?page='+page;
}

function popupOpen(select,idx){
	var popUrl = "RMSP_Check.jsp?select="+select+"&idx="+idx;	//팝업창에 출력될 페이지 URL
	var popOption = "width=400, height=125, resizable=no";    //팝업창 옵션(optoin)
		window.open(popUrl,"",popOption);
}
</script>

<%
	String pageNumberStr = request.getParameter("page");
	int pageNumber = 1;
	if (pageNumberStr != null) {
	    pageNumber = Integer.parseInt(pageNumberStr);
	} // 초기 페이지 및 선택시 선택된 페이지 설정
	List list = (List) request.getAttribute("boardlist");
	%>
<body>
<!-- <table width="600" cellpadding="2" cellspacing="0" border="1" align="center" style="position: absolute; left: 100px; top: 150px">
	<form method="get" action="./RMSSelectDB.bo">
	<tr>
		<td>팀명</td>
		<td> <input TYPE="text" NAME="TEAM_NAME" ID="TEAM_NAME" >
			 <input type="hidden" id="select" name="select" value="1"></td>
		<td> <input type="submit" value="검색"> </td>
	</tr> </form> 
	<form method="get" action="./RMSSelectDB.bo">
	<tr>
		<td>날짜만</td>
		<td> <input TYPE="date" NAME="TRANDATE" ID="TRANDATE" >
			 <input type="hidden" id="select" name="select" value="2"></td>
		<td> <input type="submit" value="검색"> </td>
	</tr> </form> 
	<form method="get" action="./RMSSelectDB.bo">
	<tr>
		<td>날짜/시간</td>
		<td> <input TYPE="date" NAME="TRANDATE2" ID="TRANDATE2" > <BR>
			 <input TYPE="text" NAME="STARTTIME" ID="STARTTIME" size="2">
		     <input TYPE="text" NAME="ENDTIME" ID="ENDTIME" size="2">
		  	 <input type="hidden" id="select" name="select" value="3"></td>
		<td> <input type="submit" value="검색"> </td>
	</tr> </form> 
	</form>
</table> -->
<P>
<br><br><br><br><br><br><br><br><br>
<div class="content_inner">
   <div class="container">
      <div class="container_inner clearfix">
<div class="wrap">
	<h1>예약리스트</h1>
	<div class="table">
		<table>
			<colgroup>
				<col width="10%" />
				<col width="10%" />
				<col width="*" />
				<col width="10%" />
				<col width="10%" />
			</colgroup>
			<thead>
				<tr>
					<th><font size="3">No.</font></th>
					<th><font size="3">팀명</font></th>
					<th><font size="3">예약일</font></th>
					<th><font size="3">예약시간</font></th>
					<th><font size="3">방</font></th>	
					<th><font size="3">비고</font></th>
				</tr>
			</thead>
			<tbody>
<%
	if(list != null){
		RMSystemModel model;
		if(pageNumber==1){
			for(int i=0; i<10; i++){
				if(i>=list.size()) break;
				model = (RMSystemModel) list.get(i);
				String yDATE = model.getTRANDATE().substring(0, 4);
				String mDATE = model.getTRANDATE().substring(4, 6);
				String dDATE = model.getTRANDATE().substring(6, model.getTRANDATE().length());
				%>
			    <tr align="center" height="25">
			        <td> <%= model.getRMS_IDX() %> </td>
			        <td> <%= model.getTEAM_NAME() %> </td>
			        <td> <%= yDATE+"/"+mDATE+"/"+dDATE %> </td>
			        <td> <%= model.getSTARTTIME()+"시~"+model.getENDTIME()+"시" %> </td>
			        <td> <%= model.getROOMSIZE() %> </td>
			        <td> <a href="javascript:popupOpen(1,<%=model.getRMS_IDX()%>);">[수정]</a>			<!-- 수정 -->
        	 			 <a href="javascript:popupOpen(2,<%=model.getRMS_IDX()%>);">[삭제]</a>			<!-- 수정 --> 
        	 			 <a href="javascript:popupOpen(3,<%=model.getRMS_IDX()%>);">[보기]</a> </td>		<!-- 수정 --> 
			    </tr>
			<%				
			}
			if(list.size()==0){ %>
			<tr><td colspan="6" align="center"> 등록된 예약이 없습니다. </td></tr>
			<%
			}
		}else{
	        for(int i=10*(pageNumber-1); i< pageNumber*10; i++){
	        	if(i>=list.size()) break;
	        	model = (RMSystemModel) list.get(i);
%>
    <tr>
        <td><%= model.getRMS_IDX() %></td>
        <td><%= model.getTEAM_NAME() %></td>
        <td><%= model.getTRANDATE() %></td>
        <td><%= model.getSTARTTIME()+"~"+model.getENDTIME() %></td>
        <td><%= model.getROOMSIZE() %></td>
        <td> <a href="javascript:popupOpen(1,<%=model.getRMS_IDX()%>);">[수정]</a>			<!-- 수정 -->
        	 <a href="javascript:popupOpen(2,<%=model.getRMS_IDX()%>);">[삭제]</a>			<!-- 수정 --> 
        	 <a href="javascript:popupOpen(3,<%=model.getRMS_IDX()%>);">[보기]</a> </td>		
    </tr>
<%      	}
	        if(list.size()==0){ %>
			<tr><td colspan="6" align="center"> 등록된 예약이 없습니다. </td></tr>
			<%
			}
		}
    }else{ 
%>
    <tr><td colspan="6" align="center"> 등록된 예약이 없습니다. </td></tr>
<% }
%>
</tbody>
</table>
<p align="center" style="margin-top: 10px">
<input type="button" value="이전페이지" onclick="pageload(this)"></td>
<% 
	if(list != null){
		for(int j=0; j< (int)(list.size()/10+1); j++){%>
			<font>&nbsp;<a href="RMSListDB.bo?page=<%=j+1%>"><%=j+1%></a>&nbsp;</font>
<%		}
	} 
%>
<input type="button" value="다음페이지" onclick="pageload(this)">
<input type="hidden" id="pageidx" name="pageidx" value="<%=pageNumber%>">
<input type="hidden" id="lastpage" name="lastpage" value="<%=(int)(list.size()/10+1)%>"><br><br>		
<a href="RMSInsert.jsp">[예약하기]</a>

</div></div></div></div></div>

</body>
</html>